package com.example.jack.community.view.me.per_setting;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.percent.PercentRelativeLayout;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.jack.community.R;
import com.example.jack.community.view.login.LoginActivity;
import com.example.jack.community.view.me.BlackStatusActivity;
import com.example.jack.community.view.me.about.AboutActivity;
import com.example.jack.community.view.me.general.GenActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 设置页面
 */
public class Setting_iconActivity extends BlackStatusActivity {

    private static final String TAG = "logins";


    //返回图片
    @BindView(R.id.img_back)
    ImageView imgBack;

    //返回文字
    @BindView(R.id.txt_back)
    TextView txtBack;

    //安全布局
    @BindView(R.id.per_sec)
    PercentRelativeLayout perSec;

    //接受行消息布局
    @BindView(R.id.per_new)
    PercentRelativeLayout perNew;

    //通用布局
    @BindView(R.id.per_gener)
    PercentRelativeLayout perGener;

    //关于布局
    @BindView(R.id.per_about)
    PercentRelativeLayout perAbout;

    //退出登录
    @BindView(R.id.per_logout)
    PercentRelativeLayout perLogout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting_icon);
        ButterKnife.bind(this);
    }


    @OnClick({R.id.img_back, R.id.txt_back, R.id.per_sec, R.id.per_new, R.id.per_gener, R.id.per_about, R.id.per_logout})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.img_back:
                finish();
                break;
            case R.id.txt_back:
                finish();
                break;
            case R.id.per_sec:
                startActivity(new Intent(Setting_iconActivity.this, Acc_secActivity.class));
                break;
            case R.id.per_new:
                startActivity(new Intent(Setting_iconActivity.this, New_MesActivity.class));
                break;
            case R.id.per_gener:
                startActivity(new Intent(Setting_iconActivity.this, GenActivity.class));
                break;
            case R.id.per_about:
                startActivity(new Intent(Setting_iconActivity.this, AboutActivity.class));
                break;
            case R.id.per_logout:
                SharedPreferences.Editor editor = getSharedPreferences("data", MODE_PRIVATE).edit();
                editor.putString("token", "null");
                editor.apply();
                Log.d(TAG, "Share: 退出登录成功");
                startActivity(new Intent(Setting_iconActivity.this, LoginActivity.class));
                break;
        }
    }
}
